#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re

unit={
    '百':100,
    '千':1000,
    '万':10000,
    '亿':100000000,
    '%':0.01
}
date = ['%Y-%m-%d', '%Y/%m/%d', '%Y.%m.%d']

def extract_number(string:str) -> float:
    '''提取字符串里的数字，有单位转化为无单位'''
    result=[]
    numberStringList = re.findall(r"\d+\.?\d*", string)
    for numberString in numberStringList:
        index=string.find(numberString)
        if index-1>=0 and string[index-1]=='-':
            result.append(-float(numberString))
        try:
            unitKey=string[index+len(numberString)]
        except IndexError:
            result.append(float(numberString))
        else:
            result.append(float(numberString)*unit.get(unitKey,1))
    return result[0]

def extract_date(string:str):
    pass

if __name__ == '__main__':
    print(extract_number('13.5万'))